<style type="text/css">
#easyTooltip{
	margin:0 10px 1em 0;
	width:450px;
	padding:8px;
	background:#fcfcfc;
	border:1px solid #e1e1e1;
	line-height:130%;	
    text-align: left;			
	}
#easyTooltip h3{
	margin:0 0 .5em 0;
	font:13px Arial, Helvetica, sans-serif;
	text-transform:uppercase;
	}	
#easyTooltip p{
	margin:0 0 .5em 0;
	}		
#easyTooltip img{
		background:#fff;
		padding:1px;
		border:1px solid #e1e1e1;
		float:left;
		margin-right:10px;
		}		

</style>
<?php
  $category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
  $category = tep_db_fetch_array($category_query);
  
  $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

  if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<div class="category_title">
    <div class="lblTitle"><?php echo $category['categories_name']; ?> <?php //echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div>
    <ul class="pagelist" style="margin-right:32px;">
        <?php echo $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?>
    </ul>
</div>
<?php
  } 
  $l=0;  
  if ($listing_split->number_of_rows > 0) {
    
    $listing_query = tep_db_query($listing_split->sql_query);
    //$row = 0;
    //echo $listing_split->sql_query;
    //print_r($listing_query);
    while ($listing = tep_db_fetch_array($listing_query)) {
  $l++;
?>

<script type="text/javascript">
    	$(document).ready(function(){	
    		$('#thum<?php echo $listing['products_id'] ?>').easyTooltip({
                <?php if($l%3==0){ ?>
                xOffset: -400,	
                <?php }else{ ?>
                xOffset: -20,
                <?php } ?>
    			useElement: 'product<?php echo $listing['products_id'] ?>'				   
    		});
    	});
//showtooltip('#thum<?php echo $listing['products_id'] ?>','#product<?php echo $listing['products_id'] ?>');
</script>
    <div id="thum<?php echo $listing['products_id'] ?>" class="product" >
        <div class="product-thumb" >
            <a href="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) ?>" title="<?php echo $listing['products_name'] ?>"><?php echo tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) ?></a>
        
       
         
        </div>
         <div class="product-price">
            <?php echo $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])); ?>
        </div>
        
        <div class="product-tit">
            <a href="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) ?>" title="<?php echo $listing['products_name'] ?>"><?php echo $listing['products_name'] ?></a>
        </div>
        
        <div align="center" style="width: 187px;    ">
        <a href="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) ?>" title="<?php echo $listing['products_name'] ?>">
           <input type="button" value="Chi tiết" title="Chi tiết" id="checkout" class="checkout">
        </a>
        
        <a  href="<?php echo tep_href_link('index.php', 'action=buy_now&products_id=' . $listing['products_id']) ?>">
            <input type="button" value="Mua" title="Mua" id="checkout" class="checkout">
        </a>
        
        </div>
         
<?php
//echo tep_get_tax_rate($listing['products_tax_class_id']);
//print_r($currencies);
//$currencies->display_price($listing['products_price']);
?>
              
    </div>
    <div style="display: none;" id="product<?php echo $listing['products_id'] ?>">
        <h3><?php echo $listing['products_name'] ?></h3>
	<?php echo tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) ?>
	<p><?php echo nl2br($listing['products_description']) ?></p>

    </div>
<?php
    }

    /*
    $list_box_contents = array();
    for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
      switch ($column_list[$col]) {
        case 'PRODUCT_LIST_MODEL':
          $lc_text = TABLE_HEADING_MODEL;
          $lc_align = '';
        break;
        case 'PRODUCT_LIST_NAME':
          $lc_text = TABLE_HEADING_PRODUCTS;
          $lc_align = '';
          break;
        case 'PRODUCT_LIST_MANUFACTURER':
          $lc_text = TABLE_HEADING_MANUFACTURER;
          $lc_align = '';
          break;
        case 'PRODUCT_LIST_PRICE':
          $lc_text = TABLE_HEADING_PRICE;
          $lc_align = 'right';
          break;
        case 'PRODUCT_LIST_QUANTITY':
          $lc_text = TABLE_HEADING_QUANTITY;
          $lc_align = 'right';
          break;
        case 'PRODUCT_LIST_WEIGHT':
          $lc_text = TABLE_HEADING_WEIGHT;
          $lc_align = 'right';
          break;
        case 'PRODUCT_LIST_IMAGE':
          $lc_text = TABLE_HEADING_IMAGE;
          $lc_align = 'center';
          break;
        case 'PRODUCT_LIST_BUY_NOW':
          $lc_text = TABLE_HEADING_BUY_NOW;
          $lc_align = 'center';
          break;
      }

      if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
        $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
      }

      $list_box_contents[0][] = array('align' => $lc_align,
                                      'params' => 'class="productListing-heading"',
                                      'text' => '&nbsp;' . $lc_text . '&nbsp;');
    }
    
    if (($rows/2) == floor($rows/2)) {
          //$list_box_contents[] = array('params' => 'class="productListing-even"');
       } else {
          //$list_box_contents[] = array('params' => 'class="productListing-odd"');
       }

        $cur_row = sizeof($list_box_contents) - 1;

       for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
          $lc_align = '';

          switch ($column_list[$col]) {
           
            case 'PRODUCT_LIST_NAME':
              $lc_align = '';
              if (isset($HTTP_GET_VARS['manufacturers_id'])) {
               $lc_text = '<div class="product-tit"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></div>';
              } else {
                $lc_text = '<div class="product-tit"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></div>';
              }
              break;
            case 'PRODUCT_LIST_MANUFACTURER':
              $lc_align = '';
              $lc_text = '&nbsp;<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a>&nbsp;';
              break;
            case 'PRODUCT_LIST_PRICE':
              $lc_align = 'right';
             if (tep_not_null($listing['specials_new_products_price'])) {
                $lc_text = '<div class="product-price">$ <s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>&nbsp;&nbsp;<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></div>';
              } else {
                $lc_text = '<div class="product-price">$ ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</div>';
              }
              break;
            case 'PRODUCT_LIST_QUANTITY':
              $lc_align = 'right';
              $lc_text = '&nbsp;' . $listing['products_quantity'] . '&nbsp;';
              break;
            case 'PRODUCT_LIST_WEIGHT':
              $lc_align = 'right';
              $lc_text = '&nbsp;' . $listing['products_weight'] . '&nbsp;';
              break;
            case 'PRODUCT_LIST_IMAGE':
              $lc_align = 'center';
              if (isset($HTTP_GET_VARS['manufacturers_id'])) {
                $lc_text = '<div class="product-thumb"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></div>';
              } else {
                $lc_text = '<div class="product-thumb"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></div>';
              }
              break;
            case 'PRODUCT_LIST_BUY_NOW':
            $lc_align = 'center';
             $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('btnbag.jpg', 'Thêm vào giỏ','class="proceedbtn"') . '</a>';
             break;
         }

        $list_box_contents[$cur_row][] = array(//'align' => $lc_align,
                                                //'params' => 'class="productListing-data"',
                                                'text'  => $lc_text);
       }

    new productListingBox_new($list_box_contents);
  */  
  } else {
    $list_box_contents = array();

    $list_box_contents[0] = array('params' => 'class="productListing-odd"');
    $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                   'text' => TEXT_NO_PRODUCTS);

    new productListingBox($list_box_contents);
  }
  

  if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>

    <div class="pagecount">
        <div class="pagenum"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div>
        <ul class="pagelist">
            <?php //TEXT_RESULT_PAGE . ' ' .  ?>
            <?php echo $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?>
        </ul>
    </div>

<?php
  }
?>
